<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head th:include="common/admin/adminHeader::html('用户管理')">
</head>

<body>
<!-- 导航栏 -->
<div th:replace="common/admin/adminNavigator::html"></div>


<script>

    $(function(){
        var data4Vue = {
            uri:"user",
            beans:[]

        };

        //ViewModel
        var vue = new Vue({
            el: '#container-fluid',
            data: data4Vue,
            mounted:function(){ //mounted　表示这个 Vue 对象加载成功了
                this.list(0);
            },
            methods: {
                list:function(pn){
                    var url =  this.uri + "/listPage?pn=" + pn;
                    axios.get(url).then(function(response) {
                        vue.beans = response.data.data;
                    });

                },
                jump:function (page) {
                    jump(page,vue);
                },
                jumpByNumber:function (pn) {
                    jumpByNumber(pn,vue);
                }

            }
        });
    });

</script>

<!-- 页面可变内容 -->
<div class="container-fluid" id="container-fluid">

    <ol class="breadcrumb">
        <li class="active">用户管理</li>
    </ol>

    <!--    表格信息-->
    <div class="row">
        <main role="main" class="col-md-10 ml-sm-auto col-lg-10 pt-3 px-4 col-lg-offset-1">
            <!--  表格内容-->
            <div class="table-responsive">
                <table class="table table-striped table-sm">
                    <thead>
                    <tr>
                        <th>#</th>
                        <th>用户名称</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr v-for="list in beans.list">

                        <td>{{list.id}}</td>
                        <td>{{list.name}}</td>

                    </tr>
                    </tbody>
                </table>
            </div>

        </main>
    </div>

    <!--分页-->
    <div class="row col-md-offset-5">
        <nav aria-label="Page navigation">
            <ul class="pagination">

                <li :class="{disabled: beans.isFirstPage}">
                    <a href="#" @click="jump('first')"><span>首页</span></a>
                </li>
                <li :class="{disabled: !beans.hasPreviousPage}">
                    <a href="#" aria-label="Previous" @click="jump('pre')">
                        <span aria-hidden="true">&laquo;</span>
                    </a>
                </li>

                <li v-for="navigatepageNum in beans.navigatepageNums"><a href="#" @click="jumpByNumber(navigatepageNum)">{{navigatepageNum}}</a></li>

                <li :class="{disabled: !beans.hasNextPage}">
                    <a href="#" aria-label="Next" @click="jump('next')">
                        <span aria-hidden="true">&raquo;</span>
                    </a>
                </li>
                <li :class="{disabled: beans.isLastPage}">
                    <a href="#" @click="jump('last')"><span>尾页</span></a>
                </li>

            </ul>
        </nav>
    </div>

</div>

</body>

</html>